﻿using DevExpress.XtraEditors.Controls;
using DevExpress.XtraEditors.Repository;
using SgAutoArchiveBrr;
using SgAutoArchiveBrrDal;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace SgAutoArchiveSp
{
    public partial class frm_Main : DevExpress.XtraBars.Ribbon.RibbonForm
    {
        private List<SgAutoArchiveBrrDal.T_CARDINFO> _listCardinfo;
        RepositoryItemButtonEdit m_OperateFoodBtn = new RepositoryItemButtonEdit();
        /// <summary>
        /// u 盘路径
        /// </summary>
        private string _sUPath = "";
       private string poldaddr ="";
        private string coldaddr = "";
        private string pnewaddr = "";
        private string cnewaddr = "";
        private byte[] _pdf;
        private Bitmap _bit3;
        public frm_Main()
        {
            InitializeComponent();
            this.WindowState = FormWindowState.Maximized;
            gridView_init();
            gridView1.CustomDrawCell += GridView1_CustomDrawCell;
            gridView1.CustomRowCellEdit += gridView1_CustomRowCellEdit;
            gridView1.RowCellClick += gridView1_RowCellClick;
            gridView1.CustomDrawRowIndicator += gridView1_CustomDrawRowIndicator;
            gridView1.IndicatorWidth = 30;

            this.Text = "泗洪县档案局档案登记查询系统" + " 欢迎您：" + Program._nowUser.U_RNAME;
        }

        protected override void WndProc(ref Message msg)
        {
            base.WndProc(ref msg);

            try
            {
                var aa = SgArchiveCommons.UDisk.GetRemovableDrivers(ref msg);
                if (aa == null || aa.Length < 1) return;

                var ds = string.Empty;
                for (int i = 0; i < aa.Length; i++)
                {
                    ds += aa[i]; ///+ Environment.NewLine;
                }
                ///
                _sUPath = ds;
                if (!_sUPath.EndsWith("\\"))
                    _sUPath = _sUPath + "\\";
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }

        private void SetEditBtn(RepositoryItemButtonEdit btn, string caption)
        { btn.Buttons[0].Kind = ButtonPredefines.Glyph;
            btn.Buttons[0].Caption = caption;
            btn.ButtonsStyle = BorderStyles.Simple;
            btn.TextEditStyle = TextEditStyles.HideTextEditor;
        }

        /// <summary>
        /// 判断是否提交过申请
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void GridView1_CustomDrawCell(object sender, DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e)
        {
            string content="";
            if (e.Column.FieldName == "是否提交")
            {
                if (e.CellValue == null)
                    return;
                
                if (e.CellValue.ToString() == "1")
                {
                    content ="待审核";
                }
                else if (e.CellValue.ToString() == "2")
                {
                    content = "审核中";
                }
                else {
                    content = "审核结束";
                }

                e.Appearance.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Near;
                e.DisplayText = content;
                if (content == "待审核")
                {
                    e.Appearance.BackColor = Color.Red;//设置此行的背景颜色}
                }
                if (content == "审核中")
                {
                    e.Appearance.BackColor = Color.Yellow;//设置此行的背景颜色}
                }
                if (content == "审核结束")
                {
                    e.Appearance.BackColor = Color.Green;//设置此行的背景颜色}
                }
                // gridControl1.RefreshDataSource();
            }
        }

      
        private void gridView1_CustomRowCellEdit(object sender, DevExpress.XtraGrid.Views.Grid.CustomRowCellEditEventArgs e)
        {

            if (e.Column.FieldName == "审批状态")
            {
                if (e.CellValue == null)
                    return;
                DataRow row = gridView1.GetDataRow(e.RowHandle);
                if (row["审批状态"].ToString() == "查阅")
                {
                    e.RepositoryItem = m_OperateFoodBtn;
                    
                }
            } 
 
        }
        /// <summary>
        /// 接待登记按钮
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void item_JDDJ_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            Dialog.Dialog_DJ dialog = new Dialog.Dialog_DJ();
            dialog.ShowDialog();
            if (dialog._enCardInfo != null)
            {
                _listCardinfo.Add(dialog._enCardInfo);
                gridView_init();
                //gridControl1.Refresh();
                //gridView1.RefreshData();
                //gridControl1.Refresh();
            }
        }

        private void gridView_init()
        {
            gridView1.GroupPanelText = "登记表格";
            gridView1.OptionsSelection.MultiSelectMode = DevExpress.XtraGrid.Views.Grid.GridMultiSelectMode.RowSelect;
            DataTable dt = new DataTable();
            dt.Columns.Add(new DataColumn("ID"));
            dt.Columns.Add(new DataColumn("登记日期"));
            dt.Columns.Add(new DataColumn("档案类型"));
            dt.Columns.Add(new DataColumn("是否提交"));
            dt.Columns.Add(new DataColumn("姓名"));
            dt.Columns.Add(new DataColumn("身份证号"));
            dt.Columns.Add(new DataColumn("性别"));
            dt.Columns.Add(new DataColumn("出生日期"));
            dt.Columns.Add(new DataColumn("户籍地址"));
            dt.Columns.Add(new DataColumn("所属派出所"));
            dt.Columns.Add(new DataColumn("身份证有效期"));
            dt.Columns.Add(new DataColumn("工作人员姓名"));
            dt.Columns.Add(new DataColumn("审批状态"));
            dt.Columns.Add(new DataColumn("备注"));
            dt.Columns.Add(new DataColumn("审批回复"));
            //repositoryItemButtonEdit1.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.HideTextEditor;
            //SgArchiveCommons.commons._uname = "1";
            // DataGridViewButtonColumn viewbutton;
            _listCardinfo = SgAutoArchiveBrrDal.Linq.T_CARDINFO_Dal.Query_TCarduname(SgArchiveCommons.commons._uname);
            if (_listCardinfo.Count>0)
            {
                foreach (var n in _listCardinfo)
                {
                    DataRow row = dt.NewRow();
                    row["ID"] = n.C_ID;
                    row["登记日期"] = n.C_DJDATE;
                    row["档案类型"] = n.C_TYPENAME;
                    row["是否提交"] = n.C_STAUTS;
                    row["姓名"] = n.C_NAME;
                    row["身份证号"] = n.C_CARDNO;
                    row["性别"] = n.C_SEX;
                    row["出生日期"] = n.C_DATE;
                    row["户籍地址"] = n.C_HJADDR;
                    row["所属派出所"] = n.C_DEPARTMENT;
                    row["身份证有效期"] = n.C_YXDATE;
                    row["工作人员姓名"] = n.C_UNAME;
                    row["备注"] = n.C_V02;
                    row["审批回复"] = n.C_V01;
                    if (n.C_I01 == 0)
                    { row["审批状态"] = "尚未审批"; }
                    if (n.C_I01 == -1)
                    {
                        row["审批状态"] = "审批不通过";

                    }
                    if (n.C_I01 == 1)
                    {
                        SetEditBtn(m_OperateFoodBtn, "查阅");
                        row["审批状态"] = "查阅";
                    }
                    dt.Rows.Add(row);

                }
                gridControl1.DataSource = dt;
                gridView1.Columns["ID"].Visible = false;  //设置列为不显示
                gridControl1.RefreshDataSource();
            }
            else {
                MessageBox.Show("暂无申请信息！");
                gridControl1.DataSource = null;
                gridControl1.RefreshDataSource();
            }
            // gridControl1.DataSource = _listCardinfo;
        }
        /// <summary>
        /// 加载列表
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void frm_Main_Load(object sender, EventArgs e)
        {
           
            // TODO: 这行代码将数据加载到表“sgAutoArchiveBrrDataSet1.T_CARDINFO”中。您可以根据需要移动或删除它。
            // this.t_CARDINFOTableAdapter.Fill(this.sgAutoArchiveBrrDataSet1.T_CARDINFO);
            // TODO: 这行代码将数据加载到表“sgAutoArchiveBrrDataSet.T_ARCHIVETYPE”中。您可以根据需要移动或删除它。
            //  this.t_ARCHIVETYPETableAdapter.Fill(this.sgAutoArchiveBrrDataSet.T_ARCHIVETYPE);

        }

        /// <summary>
        ///显示序号
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void gridView1_CustomDrawRowIndicator(object sender, DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventArgs e)
        {
            if (e.Info.IsRowIndicator && e.RowHandle >= 0)
            {
                e.Info.DisplayText = (e.RowHandle + 1).ToString();
            }
        }

        private void barButtonItem4_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {

        }


        /// <summary>
        /// 历史纪录
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void barButtonItem5_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            Form_Log fl = new Form_Log();
            fl.ShowDialog();
            if(fl._i==1)
            gridView1.GroupPanelText = "历史纪录";
            DataTable dt = new DataTable();
            dt.Columns.Add(new DataColumn("ID"));
            dt.Columns.Add(new DataColumn("登记日期"));
            dt.Columns.Add(new DataColumn("档案类型"));
            dt.Columns.Add(new DataColumn("是否提交"));
            dt.Columns.Add(new DataColumn("姓名"));
            dt.Columns.Add(new DataColumn("身份证号"));
            dt.Columns.Add(new DataColumn("性别"));
            dt.Columns.Add(new DataColumn("出生日期"));
            dt.Columns.Add(new DataColumn("户籍地址"));
            dt.Columns.Add(new DataColumn("所属派出所"));
            dt.Columns.Add(new DataColumn("身份证有效期"));
            dt.Columns.Add(new DataColumn("工作人员姓名"));
            dt.Columns.Add(new DataColumn("审批状态"));
            dt.Columns.Add(new DataColumn("备注"));
            dt.Columns.Add(new DataColumn("审批回复"));
            //repositoryItemButtonEdit1.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.HideTextEditor;
            //  SgArchiveCommons.commons._uname = "1";
            // DataGridViewButtonColumn viewbutton;
            _listCardinfo = SgAutoArchiveBrrDal.Linq.T_CARDINFO_Dal.Query_log(SgArchiveCommons.commons._uname,fl.sdt,fl.edt);
            foreach (var n in _listCardinfo)
            {
                DataRow row = dt.NewRow();
                row["ID"] = n.C_ID;
                row["登记日期"] = n.C_DJDATE;
                row["档案类型"] = n.C_TYPENAME;
                row["是否提交"] = n.C_STAUTS;
                row["姓名"] = n.C_NAME;
                row["身份证号"] = n.C_CARDNO;
                row["性别"] = n.C_SEX;
                row["出生日期"] = n.C_DATE;
                row["户籍地址"] = n.C_HJADDR;
                row["所属派出所"] = n.C_DEPARTMENT;
                row["身份证有效期"] = n.C_YXDATE;
                row["工作人员姓名"] = n.C_UNAME;
                row["审批回复"] = n.C_V01;
                row["备注"] = n.C_V02;
                if (n.C_I01 == 0)
                { row["审批状态"] = "尚未审批"; }
                if (n.C_I01 == -1)
                {
                    row["审批状态"] = "审批不通过";

                }
                if (n.C_I01 == 1)
                {
                    SetEditBtn(m_OperateFoodBtn, "查阅");
                    row["审批状态"] = "查阅";
                }
                if (n.C_I01 == 2)
                {
                    row["审批状态"] = "审批结束";

                }
                dt.Rows.Add(row);
                
            }
            gridControl1.DataSource = dt;
            gridView1.Columns["ID"].Visible = false;  //设置列为不显示
            gridControl1.RefreshDataSource();
        }

        private void gridView1_RowCellClick(object sender, DevExpress.XtraGrid.Views.Grid.RowCellClickEventArgs e)
        {
            int id;
            if (e.Column.FieldName != "审批状态") return;
            DataRow row = gridView1.GetDataRow(e.RowHandle);
            if (row == null) return;
            if (row["审批状态"].ToString() == "查阅")
            {
                int[] selectedHandle;
                selectedHandle = this.gridView1.GetSelectedRows();
                if (selectedHandle.Length > 0)
                {
                    id =int.Parse( this.gridView1.GetRowCellValue(selectedHandle[0], "ID").ToString());
                    //string name = id + ".pdf";
                    //DirectoryInfo dMax = new DirectoryInfo(Program._jyfilePath);
                    //DirectoryInfo[] dMaxChild = dMax.GetDirectories("-000003");
                    //dMaxChild[0]
                    _listCardinfo = SgAutoArchiveBrrDal.Linq.T_CARDINFO_Dal.Query_Cardid(id);

                    foreach (var n in _listCardinfo)
                    {
                        _pdf = n.c_PDF;
                        
                    }
                    //MemoryStream ms = new MemoryStream(_pdf);
                    //_bit3 = new Bitmap(ms);
                    Bytes2File(_pdf,Program._lsfilePath+"\\"+id+".pdf");
                    //_bit3.Save("1.pdf", System.Drawing.Imaging.ImageFormat.);
                     System.Diagnostics.Process.Start(Program._lsfilePath + "\\" + id + ".pdf");
                }

                //MessageBox.Show(this.gridView1.GetRowCellValue(selectedHandle[0], "身份证号").ToString());
            }   
        }

        /// <summary>
        /// 二进制转文件
        /// </summary>
        /// <param name="buff"></param>
        /// <param name="savepath"></param>
        public static void Bytes2File(byte[] buff, string savepath)
        {
            if (System.IO.File.Exists(savepath))
            {
                System.IO.File.Delete(savepath);
            }

            FileStream fs = new FileStream(savepath, FileMode.CreateNew);
            BinaryWriter bw = new BinaryWriter(fs);
            bw.Write(buff, 0, buff.Length);
            bw.Close();
            fs.Close();
        }

        /// <summary>
        /// 导出
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void barButtonItem2_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {

          

        }

        private void btn_OK_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            try
            {
                gridView1.OptionsSelection.MultiSelect = true;
                gridView1.OptionsPrint.PrintSelectedRowsOnly = true;
                gridView1.Columns["ID"].Visible = true;  //设置列为不显示
                gridControl1.RefreshDataSource();
                int[] selectedHandle;
                selectedHandle = this.gridView1.GetSelectedRows();
                if (selectedHandle.Length > 0)
                {
                    MessageBox.Show("当前共选择" + selectedHandle.Length + "条数据准备导出！");
                    string newfile = Program._filePath + "\\" + DateTime.Now.ToString("yyyyMMddHHmmss");
                    System.IO.Directory.CreateDirectory(newfile);
                    //SaveFileDialog saveFileDialog = new SaveFileDialog();
                    //saveFileDialog.Title = "导出Excel";
                    //saveFileDialog.Filter = "Excel文件(*.pdf)|*.pdf";
                    //saveFileDialog.Filter = "Excel文件(*.xls)|*.xls";
                    //saveFileDialog.FileName = newfile + "\\" + "导出数据表.xls";
                    //DialogResult dialogResult = saveFileDialog.ShowDialog(this);
                    //if (dialogResult == DialogResult.OK)
                    //{
                    DevExpress.XtraPrinting.XlsExportOptions options = new DevExpress.XtraPrinting.XlsExportOptions();
                    gridControl1.ExportToXls(newfile + "\\" + "导出数据表.xls", options);
                    // DevExpress.XtraEditors.XtraMessageBox.Show("保存成功！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    //}
                    int[] rownumber = this.gridView1.GetSelectedRows();//获取选中行号；
                    int id = 0;
                    string cardno = "";
                    for (int i = 0; i < this.gridView1.GetSelectedRows().Count(); i++)
                    {
                        DataRow row = this.gridView1.GetDataRow(rownumber[i]);//根据行号获取相应行的数据；
                        id = int.Parse(row["ID"].ToString());
                        cardno = row["身份证号"].ToString();
                        T_CARDINFO en = new T_CARDINFO();
                        en.C_STAUTS = 2;
                        en.C_I01 = 0;
                        //var query = SgAutoArchiveBrrDal.Linq.T_CARDINFO_Dal.Query_Cardid(int.Parse(row["ID"].ToString()));
                        int value = SgAutoArchiveBrrDal.Linq.T_CARDINFO_Dal.Modify_CardI01(id, en);
                         poldaddr = Program._imagePath + "\\" + cardno + "人像.jpg";
                         coldaddr = Program._imagePath + "\\" + cardno + "证件.bmp";
                         pnewaddr = newfile + "\\" + cardno + "人像.jpg";
                         cnewaddr = newfile + "\\" + cardno + "证件.bmp";
                        
                        File.Copy(poldaddr, pnewaddr);
                        File.Copy(coldaddr, cnewaddr);
                        //File.Delete(coldaddr);
                        //File.Delete(poldaddr);
                    }
                       string strtxtPath = newfile;
                        string strzipPath = newfile + ".zip";
                        System.IO.File.SetAttributes(strtxtPath, System.IO.FileAttributes.Normal);
                        string password = System.Configuration.ConfigurationSettings.AppSettings["password"];
                        SGZip.CompressFile(strtxtPath, strzipPath,null,password,6);
                        Directory.Delete(strtxtPath, true);
                   
                    if(_sUPath != "" && Directory.Exists(_sUPath))
                    {


                        if(MessageBox.Show("检测到U盘，是否直接将数据包转到U盘中?","提示",MessageBoxButtons.OKCancel, MessageBoxIcon.Question)
                          == DialogResult.OK)
                        {
                            File.Copy(strzipPath, _sUPath + strzipPath.Substring(strzipPath.LastIndexOf("\\") + 1), true);
                            gridView_init();
                            MessageBox.Show("导出成功并转入U盘中!");
                            return;
                        }
                    }

                    SaveFileDialog sa = new SaveFileDialog();
                    sa.Filter = "*.zip|*.zip";
                    if(sa.ShowDialog() == DialogResult.OK)
                    {
                        File.Copy(strzipPath, sa.FileName.Substring(0, sa.FileName.LastIndexOf("\\") + 1) +
                            strzipPath.Substring(strzipPath.LastIndexOf("\\") + 1), true);
                    }

                    gridView_init();
                    MessageBox.Show("导出成功！");
                    File.Delete(coldaddr);
                    File.Delete(poldaddr);
                }

                else
                {
                    MessageBox.Show("未选中任何数据！");
                }
            }
            catch (Exception ex)
            { MessageBox.Show(ex.ToString()); }
        }

        private void btn_close_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            gridView_init();
           
        }

        private void item_DataTongji_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (Program._nowUser.U_I01 == 1)
            {
                Dialog.Dialog_Tongji dialog = new Dialog.Dialog_Tongji();
                dialog.ShowDialog();
            }
            else
                MessageBox.Show("您无权限操作此模块!");
        }

        private void item_User_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (Program._nowUser.U_I01 == 1)
            {
                Dialog.Dialog_User dialog = new Dialog.Dialog_User();
                dialog.ShowDialog();
            }
            else
                MessageBox.Show("您无权限操作此模块!");
        }

        private void barButtonItem3_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            OpenFileDialog dialog = new OpenFileDialog();
            dialog.Multiselect = false;//该值确定是否可以选择多个文件
            dialog.DefaultExt = "zip";
            if (_sUPath != "" && Directory.Exists(_sUPath))
            {
                dialog.InitialDirectory = _sUPath;
            }

            dialog.Title = "请选择文件夹";
            dialog.Filter = "所有文件(*.zip*)|*.zip*";
            string file = "";
            if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                file = dialog.FileName;
            }
          
            string password = System.Configuration.ConfigurationSettings.AppSettings["password"];
            if (!SGZip.DecomparessFile(file, Program._jyfilePath, password))
            {
                MessageBox.Show("解压失败！");
            }
            else { MessageBox.Show("解压完成！"); }
            gridView_init();
        }

        private void barButtonItem1_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            try
            {
                int selectRow = gridView1.GetSelectedRows()[0];
                int id = int.Parse(this.gridView1.GetRowCellValue(selectRow, "ID").ToString());
                T_CARDINFO en = new T_CARDINFO();
                en.C_STAUTS = 3;
                en.C_I01 = 2;
                int value = SgAutoArchiveBrrDal.Linq.T_CARDINFO_Dal.Modify_CardI01(id, en);
                gridView_init();
                File.Delete(Program._lsfilePath  + "\\" + id + ".pdf");
            }
            catch (Exception ex)
            { }
        }

        private void barButtonItem7_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            gridView1.OptionsSelection.MultiSelectMode = DevExpress.XtraGrid.Views.Grid.GridMultiSelectMode.CheckBoxRowSelect;
            DataTable dt = new DataTable();
           
            dt.Columns.Add(new DataColumn("ID"));
            dt.Columns.Add(new DataColumn("登记日期"));
            dt.Columns.Add(new DataColumn("档案类型"));
            dt.Columns.Add(new DataColumn("是否提交"));
            dt.Columns.Add(new DataColumn("姓名"));
            dt.Columns.Add(new DataColumn("身份证号"));
            dt.Columns.Add(new DataColumn("性别"));
            dt.Columns.Add(new DataColumn("出生日期"));
            dt.Columns.Add(new DataColumn("户籍地址"));
            dt.Columns.Add(new DataColumn("所属派出所"));
            dt.Columns.Add(new DataColumn("身份证有效期"));
            dt.Columns.Add(new DataColumn("工作人员姓名"));
            dt.Columns.Add(new DataColumn("审批状态"));
            dt.Columns.Add(new DataColumn("备注"));
            dt.Columns.Add(new DataColumn("审批回复"));
            dt.Columns.Add(new DataColumn("配偶姓名"));
            dt.Columns.Add(new DataColumn("配偶身份证号"));
            dt.Columns.Add(new DataColumn("配偶性别"));
            dt.Columns.Add(new DataColumn("配偶出生年月"));
            dt.Columns.Add(new DataColumn("父亲姓名"));
            dt.Columns.Add(new DataColumn("父亲身份证号"));
            dt.Columns.Add(new DataColumn("母亲姓名"));
            dt.Columns.Add(new DataColumn("母亲身份证号"));
            dt.Columns.Add(new DataColumn("子女性别"));
            dt.Columns.Add(new DataColumn("子女出生日期"));
            dt.Columns.Add(new DataColumn("子女姓名"));
            dt.Columns.Add(new DataColumn("子女身份证号"));



            //repositoryItemButtonEdit1.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.HideTextEditor;
            // SgArchiveCommons.commons._uname = "1";
            // DataGridViewButtonColumn viewbutton;
            _listCardinfo = SgAutoArchiveBrrDal.Linq.T_CARDINFO_Dal.Query_TCarduname1(SgArchiveCommons.commons._uname);
            foreach (var n in _listCardinfo)
            {
                DataRow row = dt.NewRow();
                row["ID"] = n.C_ID;
                row["登记日期"] = n.C_DJDATE;
                row["档案类型"] = n.C_TYPENAME;
                row["是否提交"] = n.C_STAUTS;
                row["姓名"] = n.C_NAME;
                row["身份证号"] = n.C_CARDNO;
                row["性别"] = n.C_SEX;
                row["出生日期"] = n.C_DATE;
                row["户籍地址"] = n.C_HJADDR;
                row["所属派出所"] = n.C_DEPARTMENT;
                row["身份证有效期"] = n.C_YXDATE;
                row["工作人员姓名"] = n.C_UNAME;
                if (n.C_I01 == 0)
                { row["审批状态"] = "尚未审批"; }
                if (n.C_I01 == -1)
                {
                    row["审批状态"] = "审批不通过";
                    //row["审批状态"] = n.C_V01;
                }
                if (n.C_I01 == 1)
                {
                    SetEditBtn(m_OperateFoodBtn, "查阅");
                    row["审批状态"] = "查阅";
                }
                row["备注"] = n.C_V02;
                row["审批回复"] = n.C_V01;


                row["配偶姓名"] = n.C_PONAME;
                row["配偶身份证号"] = n.C_PONO;
                row["配偶性别"] = n.C_POSEX;
                row["配偶出生年月"] = n.C_PODATE;
                row["父亲姓名"] = n.C_FANAME;
                row["父亲身份证号"] = n.C_FANO;
                row["母亲姓名"] = n.C_MONAME;
                row["母亲身份证号"] = n.C_MONO;
                row["子女性别"] = n.C_SONSEX;
                row["子女出生日期"] = n.C_SONDATE;
                row["子女姓名"] = n.C_SONNAME;
                row["子女身份证号"] = n.C_SONNO;
                dt.Rows.Add(row);
            }
            gridView1.Columns.Clear();
            gridControl1.DataSource = dt;
            gridView1.Columns["ID"].Visible = true;  //设置列为不显示
            MessageBox.Show("请选择需要导出的数据并点击确认导出！");

        }

        private void gridControl1_Click(object sender, EventArgs e)
        {

        }
    }
}
